package com.leyou.listener;

import com.leyou.common.constants.RocketMQConstants;
import com.leyou.page.service.PageService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author: guojy
 * @date: 2020/3/14 17:11
 * @Description: 监听商品上架，新增静态页面
 * @version: 1.0
 */
@Slf4j
@Component
// 参数一：topic,参数二：tag，参数三：组名
@RocketMQMessageListener(topic = RocketMQConstants.TOPIC.ITEM_TOPIC_NAME,
        selectorExpression = RocketMQConstants.TAGS.ITEM_UP_TAGS,
        consumerGroup = "ITEM_PAGE_UP")
public class ItemUpListener implements RocketMQListener<Long> {

    @Autowired
    private PageService pageService;
    // 处理逻辑信息
    @Override
    public void onMessage(Long spuId) {
        log.info("[搜索服务]- (商品上架) -接收消息，spuId={}", spuId);
        pageService.createItemHtml(spuId);
    }
}
